﻿using System;
using System.IO;

namespace SpeedSearch
{
    public class FileParsing : IDisposable
    {
        public StreamReader fileToParse { get; set; }
        public string StringToSearch { get; set; }

        public FileParsing(string aFile)
        {
            this.fileToParse = new StreamReader(aFile);
        }

        public bool IsFileContainingString(bool caseSensitive)
        {
            if (caseSensitive)
                return this.GetContents().IndexOf(StringToSearch, StringComparison.Ordinal) >= 0;
            else
                return this.GetContents().IndexOf(StringToSearch, StringComparison.OrdinalIgnoreCase) >= 0;
        }

        public string GetContents()
        {
            return this.fileToParse.ReadToEnd();
        }

        public void Dispose()
        {
            fileToParse = null;
        }
    }
}
